/*
 * 作者:熊猫
 * 日期:2017 - 3 - 20 11 - 43 - 37
 *
 */

package net.lainiao.morethread.Chapter8.demo5;


import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;

/**
 * Created by Administrator on 2017/3/20.
 */
public class MyFormatter extends Formatter {
    public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");

    @Override
    public String format(LogRecord record) {
        StringBuilder sb = new StringBuilder();
        sb.append("[" + record.getLevel() + "]");
        String date = DATE_FORMAT.format(new Date(record.getMillis()));
        sb.append(date + ":");
        sb.append(record.getSourceClassName() + "." + record.getSourceMethodName() + ":");
        sb.append(record.getMessage() + "\n");
        return sb.toString();
    }
}
